/*设置日期框*/
$(function () {
    laydate.render({
        elem:'[name=noticePubDate]'
    });
});

function search(){
    var param = {};
    param.noticeTitle = $("#condition [name=noticeTitle]").val();
    param.noticePubDate = $("#condition [name=noticePubDate]").val();
    $("#noticeTable").bootstrapTable("refresh", {query: param});
}

function formatOpt(noticeId){
    return '<a href="'+ctx+'/director/noticeInfo/viewNoticeInfoByNoticeId?noticeId='+noticeId+'">查看</a>';
}


$(function(){
    initAddNoticeInfo();
});


/*初始化发布公告*/
function initAddNoticeInfo(){
    $("#addNoticeInfo").dialog({
        title: '发布公告',
        btnValue: '确认发布',
        btnBind: function () {
            var $form = $(".modal-body").find("#addNoticeInfo_form");
            var params = $form.serialize();
            var noticeTitle = $form.find("[name=noticeTitle]").val();
            var noticeContent = $form.find("[name=noticeContent]").val();
            if(noticeTitle==null || noticeTitle=='' || noticeContent==null || noticeContent==''){
                swal("信息提示","信息提示不完整!","warning");
                return;
            }

            if(params!=null && params.length>0){
                $.post(ctx+"/director/noticeInfo/addNoticeInfo",params,function (msg) {
                    $("#addNoticeInfo").dialog("close");
                    $("#noticeTable").bootstrapTable("refresh");
                    toastr.info(msg);
                });
            }else{
                $("#addNoticeInfo").dialog("close");
            }
        }
    });
};

/*发布公告*/
function addNoticeInfo(){
    $("#addNoticeInfo").find("form")[0].reset();
    $("#addNoticeInfo").dialog("open");
}